﻿@{
    ViewBag.Title = "Список продуктов";
}

<h2>Список продуктов</h2>
<div id="TableContainer"></div>

@section style
{
    <link rel="stylesheet" href="~/static/plugins/jui/css/ui-lightness/jquery-ui-1.10.3.custom.min.css">
    <link rel="stylesheet" href="~/static/plugins/jtable/themes/lightcolor/blue/jtable.min.css">
}
@section script_bottom
{
    <script type="text/javascript" src="~/static/plugins/jui/js/jquery-ui-1.10.3.custom.min.js"></script>
    <script type="text/javascript" src="~/static/plugins/jtable/jquery.jtable.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $('#TableContainer').jtable({
                title: 'Свойства продуктов',
                actions: {
                    listAction: '@Url.Action("ListProperty")',
                    createAction: '/',
                    updateAction: '/',
                    deleteAction: '/'
                },
                fields: {
                    Id: {
                        key: true,
                        list: false
                    },
                    Name: {
                        title: 'Имя'
                    },
                    Price: {
                        title: "Цена"
                    },
                    Alias: {
                        title: "Псевдоним"
                    },
                    IsActive: {
                        title: "Активность",
                        type: 'checkbox',
                        values: { 'false': 'Не активно', 'true': 'Активно' },
                    }
                },
                formCreated: function (event, data) {
                    $(".ui-dialog").hide();
                    $(".ui-widget-overlay").hide();
                    if (data.formType == "create") {
                        window.location.href = "@Url.Action("Add")";
                    } else {
                        window.location.href = "@Url.Action("Edit")/" + data.record.Id;
                    }
                }
            });
            $('#TableContainer').jtable('load');
        });
    </script>
}
